package com.jy.adscm.operation.mscyb.service.impl;

import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.mscyb.bean.JqcsSetting;
import com.jy.adscm.operation.mscyb.bean.JqfzSetting;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqfzSettingMapper;
import com.jy.adscm.operation.mscyb.service.JqfzSettingService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import com.jy.adscm.zltx.bean.JyDrawingType;
import com.jy.adscm.zltx.mapper.mysql.JyDrawingTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-06-15
 */
@Service
public class JqfzSettingServiceImpl extends ServiceImpl<JqfzSettingMapper, JqfzSetting> implements JqfzSettingService {
     @Autowired
    JyUserMapper jyUserMapper;
     @Autowired
    JyDrawingTypeMapper jyDrawingTypeMapper;
    @Override
    public JqfzSetting selectJqfzSettingById(String id) {
        JqfzSetting jqfzSetting = super.selectById(id);
        if (AdscmBaseUtils.getInstance().isNotEmpty(jqfzSetting,null)){
            if (AdscmBaseUtils.getInstance().isNotEmpty(jqfzSetting.getCreator(),null)){
                JyUser jyUser = jyUserMapper.selectById(jqfzSetting.getCreator());
                jqfzSetting.setCreatorName(jyUser.getName());
            }

        }
        return jqfzSetting;
    }

    @Override
    public List<JqfzSetting> selectAll() {
        List<JqfzSetting> jqfzSettings = super.selectList(null);
        for (JqfzSetting jqfzSetting : jqfzSettings) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(jqfzSetting.getCreator(),null)){
                JyUser jyUser = jyUserMapper.selectById(jqfzSetting.getCreator());
                jqfzSetting.setCreatorName(jyUser.getName());
            }

            if (AdscmBaseUtils.getInstance().isNotEmpty(jqfzSetting.getType(),null)){
                JyDrawingType jyDrawingType = jyDrawingTypeMapper.selectById(jqfzSetting.getType());
                jqfzSetting.setTypeName(jyDrawingType.getType());
            }
        }
        return jqfzSettings;
    }
}
